package main

import (
    "fmt"
    "github.com/PuerkitoBio/goquery"
    "github.com/astaxie/beego/orm"
    _ "github.com/go-sql-driver/mysql" // import your used driver
    "github.com/hu17889/go_spider/core/common/page"
    "github.com/hu17889/go_spider/core/pipeline"
    "github.com/hu17889/go_spider/core/spider"
    "github.com/json-iterator/go"
    _ "github.com/lib/pq"
    "github.com/sony/sonyflake"
    "strings"
    "sync"
    "time"
)
var sf *sonyflake.Sonyflake
var o orm.Ormer
var wg sync.WaitGroup

type MyPageProcesser struct {
    target AuctionTarget
}

type AuctionItem struct {
    Id int64 `orm:"column(id);pk"`
    AuctionTarget  *AuctionTarget `orm:"rel(fk)"`    //设置一对多关系
    MnNotice bool `json:"mnNotice"` // mysql 可以使用这种方式`json:"mnNotice" orm:"description(注释)"`注释 但是postgresql不行
    Credit bool `json:"credit"`
    ItemUrl string `json:"itemUrl"`
    Status string `json:"status"`
    Title string `json:"title"`
    PicUrl string `json:"picUrl"`
    InitialPrice float32 `json:"initialPrice"`
    CurrentPrice float32 `json:"currentPrice"`
    ConsultPrice float32 `json:"consultPrice"`
    MarketPrice float32 `json:"marketPrice"`
    SellOff bool `json:"sellOff"`
    Start int64 `json:"start"`
    End int64 `json:"end"`
    TimeToStart int64 `json:"timeToStart"`
    TimeToEnd int64 `json:"timeToEnd"`
    ViewerCount int64 `json:"viewerCount"`
    BidCount int64 `json:"bidCount"`
    DelayCount int64 `json:"delayCount"`
    ApplyCount int64 `json:"applyCount"`
    CatNames string `json:"catNames"`
    CollateralCatName string `json:"collateralCatName"`
    XmppVersion string `json:"xmppVersion"`
    BuyRestrictions int64 `json:"buyRestrictions"`
    SupportLoans int64 `json:"supportLoans"`
    SupportOrgLoan int64 `json:"supportOrgLoan"`
    UpdateTime time.Time
}
// Model Struct
type AuctionTarget struct {
    Id uint64 `orm:"pk"`
    AuctionItem []*AuctionItem `orm:"reverse(many)"` // 设置一对多的反向关系
    Category string
    Url string
    CityOrLocation string // 城市或者区 主要是为了对应拍卖记录的位置信息 可以设置为 宁波>鄞州
    Available bool `orm:"default(true)"`
    CreateTime time.Time
}

func init() {
    //// set default database
    //orm.RegisterDataBase("default", "mysql", "root:root@tcp(192.168.31.75:3306)/aoi?charset=utf8", 30)
    //
    //// register model
    //orm.RegisterModel(new(User))
    //
    //// create table
    //orm.RunSyncdb("default", false, true)

    _ = orm.RegisterDriver("postgres", orm.DRPostgres)

    _ = orm.RegisterDataBase("default", "postgres", "postgres://postgres:baymin1024@rest.yining.site/spider?sslmode=disable")

    orm.RegisterModel(new(AuctionTarget), new(AuctionItem))
    // create table
    _ = orm.RunSyncdb("default", false, true)

    sf = sonyflake.NewSonyflake(sonyflake.Settings{})
    if sf == nil {
        fmt.Printf("sonyflake not created")
    }
    o = orm.NewOrm()
}
func NewMyPageProcesser(auc AuctionTarget) *MyPageProcesser {
    return &MyPageProcesser{target:auc}
}

// Parse html dom here and record the parse result that we want to crawl.
// Package simplejson (https://github.com/bitly/go-simplejson) is used to parse data of json.
func (this *MyPageProcesser) Process(p *page.Page) {
    if !p.IsSucc() {
        println(p.Errormsg())
        return
    }

    query := p.GetHtmlParser()

    query.Find(".J_Pagination").Each(func(i int, selection *goquery.Selection) {
        selection.Find(".next").Each(func(i int, se *goquery.Selection) {
            href, b :=se.Attr("href")
            if b{
                fmt.Println("每页%s", strings.TrimSpace(href))
                p.AddTargetRequest("https:" + strings.TrimSpace(href), "html")
            }
        })
    })



    query.Find("#sf-item-list-data").Each(func(i int, s *goquery.Selection) {

        jsonStr := s.Text()
        //fmt.Printf(jsonStr)
        //jsonStr := `{"data":[{"id":610880691509,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610880691509.htm","status":"doing","title":"慈溪市浒山街道时代华都1号楼1502室及-1-42车位","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1agwYrKT2gK0jSZFvkEJnFXXa","initialPrice":1560000.00,"currentPrice":1560000.00,"consultPrice":2781800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":3080,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610744758708,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610744758708.htm","status":"doing","title":"位于宁波市北仑区新碶好时光大厦汽1幢汽06","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB11Kgkr.Y1gK0jSZFM2UCWcVXa","initialPrice":26000.00,"currentPrice":26000.00,"consultPrice":46400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":1054,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610691298028,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610691298028.htm","status":"doing","title":"宁波市鄞州区首南街道鄞县大道东段1299号鄞州商会大厦2203室的商业房地产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1r_Wmr.Y1gK0jSZFM7SaWcVXa","initialPrice":4860000.00,"currentPrice":4860000.00,"consultPrice":7590000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":2988,"bidCount":0,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610652078857,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610652078857.htm","status":"doing","title":"慈溪市浒山街道时代华都1号楼1501室及-1-25车位","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1tAc2rKL2gK0jSZFmMb37iXXa","initialPrice":1720000.00,"currentPrice":1720000.00,"consultPrice":3076200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":2505,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610503173438,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610503173438.htm","status":"doing","title":"位于宁波市北仑区新碶好时光大厦汽1幢汽02","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB11Mcir1L2gK0jSZPhBQ9hvXXa","initialPrice":28000.00,"currentPrice":28000.00,"consultPrice":50000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":885,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610449845042,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610449845042.htm","status":"doing","title":"宁波市鄞州区世纪大道北段555号（名汇东方）002幢13-1办公房地产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB17Xqor7L0gK0jSZFATwwA9pXa","initialPrice":2016000.00,"currentPrice":2016000.00,"consultPrice":3140000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":2520,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610448821311,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610448821311.htm","status":"doing","title":"宁波市镇海区蛟川街道金锚路465号银凤晓月63号501室的房屋","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1nrBltkL0gK0jSZFAHO3A9pXa","initialPrice":1150000.00,"currentPrice":1150000.00,"consultPrice":1573000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":7096,"bidCount":9,"delayCount":0,"applyCount":7,"catNames":"","collateralCatName":"","xmppVersion":"11","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610286679166,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610286679166.htm","status":"doing","title":"位于北仑区新碶黄山路178号地产房地产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1V6_LpKbviK0jSZFNHCKApXXa","initialPrice":1715000.00,"currentPrice":1715000.00,"consultPrice":2450000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":4210,"bidCount":1,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610230839991,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610230839991.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-40房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1AuHJqlv0gK0jSZKbHPPK2FXa","initialPrice":56000.00,"currentPrice":56000.00,"consultPrice":79200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":1527,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610229791708,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610229791708.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P2-47房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1ThrHqi_1gK0jSZFqI9UpaXXa","initialPrice":62100.00,"currentPrice":62100.00,"consultPrice":88600.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":1238,"bidCount":1,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610226216819,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610226216819.htm","status":"doing","title":"余姚市城区北滨江路57弄5号的房产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1Y4vTr.z1gK0jSZLepgj9kVXa","initialPrice":3640000.00,"currentPrice":3640000.00,"consultPrice":6483300.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":5376,"bidCount":1,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610203475179,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610203475179.htm","status":"doing","title":"慈溪市浒山街道城市星光苑2#楼1706室住宅房地产（含第二单元阁楼）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1Jx5rqbr1gK0jSZR0_2zP8XXa","initialPrice":1670000.00,"currentPrice":1670000.00,"consultPrice":2376100.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":2712,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610202923543,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610202923543.htm","status":"doing","title":"慈溪市浒山街道城市星光苑2#楼1703室住宅房地产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1yiOrqeH2gK0jSZFE1G3qMpXa","initialPrice":1810000.00,"currentPrice":1810000.00,"consultPrice":2577800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":2131,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610201947740,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610201947740.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-38房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1g1KpqkY2gK0jSZFgDwM5OFXa","initialPrice":56400.00,"currentPrice":56400.00,"consultPrice":80500.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":1191,"bidCount":1,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610201651678,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610201651678.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-37房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB16GCnqkP2gK0jSZPx2oqcQpXa","initialPrice":56400.00,"currentPrice":56400.00,"consultPrice":80500.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":1159,"bidCount":1,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610189679635,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610189679635.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号202室及13号-1-37室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1HZhltlv0gK0jSZKb5qYK2FXa","initialPrice":1130000.00,"currentPrice":1130000.00,"consultPrice":1614000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":6938,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610189075954,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610189075954.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号104室及13号-1-15室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1F4tpthD1gK0jSZFyHzZiOVXa","initialPrice":1176000.00,"currentPrice":1176000.00,"consultPrice":1680000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":4879,"bidCount":0,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610188563899,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610188563899.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号102室及13号-1-13室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1nUVothD1gK0jSZFKrqAJrVXa","initialPrice":1165000.00,"currentPrice":1165000.00,"consultPrice":1664000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":4912,"bidCount":0,"delayCount":0,"applyCount":3,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610187027166,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610187027166.htm","status":"doing","title":"余姚市城区金色兰庭18幢1305室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1x5hRqeH2gK0jSZFE23cqMpXa","initialPrice":845000.00,"currentPrice":845000.00,"consultPrice":1197400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":4885,"bidCount":2,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610186507117,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610186507117.htm","status":"doing","title":"余姚市城区金色兰庭18幢1304室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1TUNOqkP2gK0jSZPxYWacQpXa","initialPrice":845000.00,"currentPrice":845000.00,"consultPrice":1197400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2911,"bidCount":2,"delayCount":0,"applyCount":10,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610185383198,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610185383198.htm","status":"doing","title":"余姚市城区金色兰庭18幢1105室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1KmdMqbr1gK0jSZFD6Z_9yVXa","initialPrice":845000.00,"currentPrice":845000.00,"consultPrice":1186400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2713,"bidCount":2,"delayCount":0,"applyCount":8,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610185259632,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610185259632.htm","status":"doing","title":"余姚市城区金色兰庭18幢1102室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB14cJMqkL0gK0jSZFtkflQCXXa","initialPrice":850000.00,"currentPrice":850000.00,"consultPrice":1186400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2827,"bidCount":3,"delayCount":0,"applyCount":7,"catNames":"","collateralCatName":"","xmppVersion":"5","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610184459220,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610184459220.htm","status":"doing","title":"余姚市城区金色兰庭18幢804室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1HkxNqhD1gK0jSZFKi.cJrVXa","initialPrice":835000.00,"currentPrice":835000.00,"consultPrice":1175200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2774,"bidCount":2,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610184103284,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610184103284.htm","status":"doing","title":"余姚市城区金色兰庭18幢705室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB10_lKqkY2gK0jSZFgklE5OFXa","initialPrice":825000.00,"currentPrice":825000.00,"consultPrice":1164200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":3163,"bidCount":2,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610134247407,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610134247407.htm","status":"doing","title":"余姚市城区金色兰庭17幢802室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1p.7wpWL7gK0jSZFBppFZZpXa","initialPrice":1420000.00,"currentPrice":1420000.00,"consultPrice":2027700.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":3971,"bidCount":1,"delayCount":0,"applyCount":3,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610133883334,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610133883334.htm","status":"doing","title":"余姚市城区金色兰庭17幢702室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB12ZQzp4D1gK0jSZFsdRnldVXa","initialPrice":930000.00,"currentPrice":930000.00,"consultPrice":1316300.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":3576,"bidCount":1,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"3","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":610119107692,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610119107692.htm","status":"doing","title":"宁波杭州湾新区庵东镇人和街195号住宅房地产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1ESr7pYY1gK0jSZTEiahDQVXa","initialPrice":597000.00,"currentPrice":597000.00,"consultPrice":844700.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":11343,"bidCount":2,"delayCount":0,"applyCount":9,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610005490692,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610005490692.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-41房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1fYTQqhv1gK0jSZFF7zD0sXXa","initialPrice":57300.00,"currentPrice":57300.00,"consultPrice":81800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1236,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":610003418164,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610003418164.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-36房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1x4TIqhD1gK0jSZFyX0ciOVXa","initialPrice":56400.00,"currentPrice":56400.00,"consultPrice":80500.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1156,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":609975830576,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609975830576.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P4-85房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1ReutqbY1gK0jSZTE7ChDQVXa","initialPrice":62100.00,"currentPrice":62100.00,"consultPrice":88600.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1208,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":609974994989,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609974994989.htm","status":"doing","title":"慈溪市浒山街道城市星光苑1#楼1606室住宅房地产（含第二单元阁楼）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB16aCoqXP7gK0jSZFjJmw5aXXa","initialPrice":1660000.00,"currentPrice":1660000.00,"consultPrice":2366800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":2343,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":609974366944,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609974366944.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P4-86房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1joKnqkL0gK0jSZFx76JWHVXa","initialPrice":56100.00,"currentPrice":56100.00,"consultPrice":80100.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1129,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":609972834316,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609972834316.htm","status":"doing","title":"宁波市海曙区高塘路29弄15号2幢D204住宅房地产（含室内固定装修及动产）","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1zGGgqkP2gK0jSZPxIyicQpXa","initialPrice":2600000.00,"currentPrice":2600000.00,"consultPrice":3662800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":3713,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0},{"id":609969682431,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609969682431.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号204室及13号-1-54室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB10f0ptkT2gK0jSZPcZiUKkpXa","initialPrice":1148000.00,"currentPrice":1148000.00,"consultPrice":1639000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":4175,"bidCount":0,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":609958206355,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609958206355.htm","status":"doing","title":"余姚市城区金色兰庭18幢904室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1rktJqoz1gK0jSZLeKo_9kVXa","initialPrice":830000.00,"currentPrice":830000.00,"consultPrice":1175200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":2468,"bidCount":1,"delayCount":0,"applyCount":3,"catNames":"","collateralCatName":"","xmppVersion":"3","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":609957402324,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609957402324.htm","status":"doing","title":"余姚市城区金色兰庭17幢701室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB15iNIqbr1gK0jSZFD2Fr9yVXa","initialPrice":1165000.00,"currentPrice":1165000.00,"consultPrice":1325900.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":4408,"bidCount":24,"delayCount":0,"applyCount":9,"catNames":"","collateralCatName":"","xmppVersion":"26","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":609906150373,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609906150373.htm","status":"doing","title":"余姚市城区金色兰庭17幢602室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1gVszp7L0gK0jSZFtubtQCXXa","initialPrice":920000.00,"currentPrice":920000.00,"consultPrice":1304100.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":2750,"bidCount":1,"delayCount":0,"applyCount":7,"catNames":"","collateralCatName":"","xmppVersion":"3","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":609904950544,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609904950544.htm","status":"doing","title":"余姚市城区金色兰庭17幢201室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB16tEvp1T2gK0jSZFvuUVnFXXa","initialPrice":890000.00,"currentPrice":890000.00,"consultPrice":1263900.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":2604,"bidCount":0,"delayCount":0,"applyCount":5,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1},{"id":609808217536,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609808217536.htm","status":"doing","title":"宁波市海曙区（原鄞州区）集士港镇格兰春晨10幢46号105室的房地产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB190FWqAT2gK0jSZFkY4UIQFXa","initialPrice":1750000.00,"currentPrice":1750000.00,"consultPrice":2195000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":4461,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}]}`

        var bb []AuctionItem
        var json = jsoniter.ConfigCompatibleWithStandardLibrary
        json.Unmarshal([]byte(jsoniter.Get([]byte(jsonStr), "data").ToString()), &bb)



        for i:=0; i<len(bb);i++  {
            bb[i].UpdateTime = time.Unix(bb[i].Start/1000, 0)
            bb[i].AuctionTarget = &this.target

            itemUrl := strings.TrimSpace(bb[i].ItemUrl)
            if !strings.Contains(itemUrl, "https:"){
                itemUrl = "https:" + itemUrl
                bb[i].ItemUrl = itemUrl
            }
            picUrl := strings.TrimSpace(bb[i].PicUrl)
            if !strings.Contains(picUrl, "https:"){
                picUrl = "https:" + picUrl
                bb[i].PicUrl = picUrl
            }

            _, e := o.Insert(&bb[i])
            if e!=nil && strings.Contains(e.Error(), "duplicate key value violates unique constraint") {
                // handle error
                _, _ = o.Update(&bb[i])
            }
            //fmt.Printf("UID: %d, ERR: %v\n", uid, e)
        }
        //json := goquery.NewDocumentFromReader(strin)
    })
    //println(p.GetTargetRequests())
}

func (this *MyPageProcesser) Finish() {
    fmt.Printf("TODO:before end spider \r\n")
    wg.Done()
}

func main() {
    xa := time.Unix(1577066400000/1000, 0)
    fmt.Printf(xa.String())
    //s := Student{"xiaoming",10,4}
    //
    //result, err := json.Marshal(s)
    //
    //fmt.Printf("%s\n",result)
    //
    //stu := new(Student)

    //json.Unmarshal([]byte(`{"data":[{"id":610880691509,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610880691509.htm","status":"doing","title":"慈溪市浒山街道时代华都1号楼1502室及-1-42车位","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1agwYrKT2gK0jSZFvkEJnFXXa","initialPrice":1560000.00,"currentPrice":1560000.00,"consultPrice":2781800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":3080,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610744758708,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610744758708.htm","status":"doing","title":"位于宁波市北仑区新碶好时光大厦汽1幢汽06","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB11Kgkr.Y1gK0jSZFM2UCWcVXa","initialPrice":26000.00,"currentPrice":26000.00,"consultPrice":46400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":1054,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610691298028,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610691298028.htm","status":"doing","title":"宁波市鄞州区首南街道鄞县大道东段1299号鄞州商会大厦2203室的商业房地产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1r_Wmr.Y1gK0jSZFM7SaWcVXa","initialPrice":4860000.00,"currentPrice":4860000.00,"consultPrice":7590000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":2988,"bidCount":0,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610652078857,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610652078857.htm","status":"doing","title":"慈溪市浒山街道时代华都1号楼1501室及-1-25车位","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1tAc2rKL2gK0jSZFmMb37iXXa","initialPrice":1720000.00,"currentPrice":1720000.00,"consultPrice":3076200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":2505,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610503173438,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610503173438.htm","status":"doing","title":"位于宁波市北仑区新碶好时光大厦汽1幢汽02","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB11Mcir1L2gK0jSZPhBQ9hvXXa","initialPrice":28000.00,"currentPrice":28000.00,"consultPrice":50000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":885,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610449845042,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610449845042.htm","status":"doing","title":"宁波市鄞州区世纪大道北段555号（名汇东方）002幢13-1办公房地产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB17Xqor7L0gK0jSZFATwwA9pXa","initialPrice":2016000.00,"currentPrice":2016000.00,"consultPrice":3140000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":2520,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610448821311,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610448821311.htm","status":"doing","title":"宁波市镇海区蛟川街道金锚路465号银凤晓月63号501室的房屋","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1nrBltkL0gK0jSZFAHO3A9pXa","initialPrice":1150000.00,"currentPrice":1150000.00,"consultPrice":1573000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790831,"timeToEnd":56609169,"viewerCount":7096,"bidCount":9,"delayCount":0,"applyCount":7,"catNames":"","collateralCatName":"","xmppVersion":"11","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610286679166,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610286679166.htm","status":"doing","title":"位于北仑区新碶黄山路178号地产房地产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1V6_LpKbviK0jSZFNHCKApXXa","initialPrice":1715000.00,"currentPrice":1715000.00,"consultPrice":2450000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":4210,"bidCount":1,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610230839991,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610230839991.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-40房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1AuHJqlv0gK0jSZKbHPPK2FXa","initialPrice":56000.00,"currentPrice":56000.00,"consultPrice":79200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":1527,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610229791708,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610229791708.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P2-47房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1ThrHqi_1gK0jSZFqI9UpaXXa","initialPrice":62100.00,"currentPrice":62100.00,"consultPrice":88600.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":1238,"bidCount":1,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610226216819,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610226216819.htm","status":"doing","title":"余姚市城区北滨江路57弄5号的房产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1Y4vTr.z1gK0jSZLepgj9kVXa","initialPrice":3640000.00,"currentPrice":3640000.00,"consultPrice":6483300.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":5376,"bidCount":1,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610203475179,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610203475179.htm","status":"doing","title":"慈溪市浒山街道城市星光苑2#楼1706室住宅房地产（含第二单元阁楼）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1Jx5rqbr1gK0jSZR0_2zP8XXa","initialPrice":1670000.00,"currentPrice":1670000.00,"consultPrice":2376100.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":2712,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610202923543,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610202923543.htm","status":"doing","title":"慈溪市浒山街道城市星光苑2#楼1703室住宅房地产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1yiOrqeH2gK0jSZFE1G3qMpXa","initialPrice":1810000.00,"currentPrice":1810000.00,"consultPrice":2577800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":2131,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610201947740,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610201947740.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-38房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1g1KpqkY2gK0jSZFgDwM5OFXa","initialPrice":56400.00,"currentPrice":56400.00,"consultPrice":80500.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790832,"timeToEnd":56609168,"viewerCount":1191,"bidCount":1,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610201651678,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610201651678.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-37房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB16GCnqkP2gK0jSZPx2oqcQpXa","initialPrice":56400.00,"currentPrice":56400.00,"consultPrice":80500.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":1159,"bidCount":1,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610189679635,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610189679635.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号202室及13号-1-37室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1HZhltlv0gK0jSZKb5qYK2FXa","initialPrice":1130000.00,"currentPrice":1130000.00,"consultPrice":1614000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":6938,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610189075954,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610189075954.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号104室及13号-1-15室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1F4tpthD1gK0jSZFyHzZiOVXa","initialPrice":1176000.00,"currentPrice":1176000.00,"consultPrice":1680000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":4879,"bidCount":0,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610188563899,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610188563899.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号102室及13号-1-13室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1nUVothD1gK0jSZFKrqAJrVXa","initialPrice":1165000.00,"currentPrice":1165000.00,"consultPrice":1664000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":4912,"bidCount":0,"delayCount":0,"applyCount":3,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610187027166,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610187027166.htm","status":"doing","title":"余姚市城区金色兰庭18幢1305室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1x5hRqeH2gK0jSZFE23cqMpXa","initialPrice":845000.00,"currentPrice":845000.00,"consultPrice":1197400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":4885,"bidCount":2,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610186507117,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610186507117.htm","status":"doing","title":"余姚市城区金色兰庭18幢1304室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1TUNOqkP2gK0jSZPxYWacQpXa","initialPrice":845000.00,"currentPrice":845000.00,"consultPrice":1197400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2911,"bidCount":2,"delayCount":0,"applyCount":10,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610185383198,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610185383198.htm","status":"doing","title":"余姚市城区金色兰庭18幢1105室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1KmdMqbr1gK0jSZFD6Z_9yVXa","initialPrice":845000.00,"currentPrice":845000.00,"consultPrice":1186400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2713,"bidCount":2,"delayCount":0,"applyCount":8,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610185259632,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610185259632.htm","status":"doing","title":"余姚市城区金色兰庭18幢1102室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB14cJMqkL0gK0jSZFtkflQCXXa","initialPrice":850000.00,"currentPrice":850000.00,"consultPrice":1186400.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2827,"bidCount":3,"delayCount":0,"applyCount":7,"catNames":"","collateralCatName":"","xmppVersion":"5","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610184459220,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610184459220.htm","status":"doing","title":"余姚市城区金色兰庭18幢804室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1HkxNqhD1gK0jSZFKi.cJrVXa","initialPrice":835000.00,"currentPrice":835000.00,"consultPrice":1175200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790833,"timeToEnd":56609167,"viewerCount":2774,"bidCount":2,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610184103284,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610184103284.htm","status":"doing","title":"余姚市城区金色兰庭18幢705室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB10_lKqkY2gK0jSZFgklE5OFXa","initialPrice":825000.00,"currentPrice":825000.00,"consultPrice":1164200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":3163,"bidCount":2,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610134247407,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610134247407.htm","status":"doing","title":"余姚市城区金色兰庭17幢802室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1p.7wpWL7gK0jSZFBppFZZpXa","initialPrice":1420000.00,"currentPrice":1420000.00,"consultPrice":2027700.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":3971,"bidCount":1,"delayCount":0,"applyCount":3,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610133883334,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610133883334.htm","status":"doing","title":"余姚市城区金色兰庭17幢702室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB12ZQzp4D1gK0jSZFsdRnldVXa","initialPrice":930000.00,"currentPrice":930000.00,"consultPrice":1316300.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":3576,"bidCount":1,"delayCount":0,"applyCount":4,"catNames":"","collateralCatName":"","xmppVersion":"3","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":610119107692,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610119107692.htm","status":"doing","title":"宁波杭州湾新区庵东镇人和街195号住宅房地产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1ESr7pYY1gK0jSZTEiahDQVXa","initialPrice":597000.00,"currentPrice":597000.00,"consultPrice":844700.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":11343,"bidCount":2,"delayCount":0,"applyCount":9,"catNames":"","collateralCatName":"","xmppVersion":"4","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610005490692,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610005490692.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-41房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1fYTQqhv1gK0jSZFF7zD0sXXa","initialPrice":57300.00,"currentPrice":57300.00,"consultPrice":81800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1236,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":610003418164,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/610003418164.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P1-36房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB1x4TIqhD1gK0jSZFyX0ciOVXa","initialPrice":56400.00,"currentPrice":56400.00,"consultPrice":80500.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1156,"bidCount":0,"delayCount":0,"applyCount":1,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":609975830576,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609975830576.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P4-85房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB1ReutqbY1gK0jSZTE7ChDQVXa","initialPrice":62100.00,"currentPrice":62100.00,"consultPrice":88600.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1208,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":609974994989,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609974994989.htm","status":"doing","title":"慈溪市浒山街道城市星光苑1#楼1606室住宅房地产（含第二单元阁楼）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB16aCoqXP7gK0jSZFjJmw5aXXa","initialPrice":1660000.00,"currentPrice":1660000.00,"consultPrice":2366800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":2343,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":609974366944,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609974366944.htm","status":"doing","title":"宁波市奉化区溪口镇福明花园P4-86房地产（车库）","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1joKnqkL0gK0jSZFx76JWHVXa","initialPrice":56100.00,"currentPrice":56100.00,"consultPrice":80100.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790834,"timeToEnd":56609166,"viewerCount":1129,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":609972834316,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609972834316.htm","status":"doing","title":"宁波市海曙区高塘路29弄15号2幢D204住宅房地产（含室内固定装修及动产）","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1zGGgqkP2gK0jSZPxIyicQpXa","initialPrice":2600000.00,"currentPrice":2600000.00,"consultPrice":3662800.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":3713,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"1","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":0}{"id":609969682431,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609969682431.htm","status":"doing","title":"宁波市镇海区蛟川街道中官路333号红墅湾8号204室及13号-1-54室的汽车位","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB10f0ptkT2gK0jSZPcZiUKkpXa","initialPrice":1148000.00,"currentPrice":1148000.00,"consultPrice":1639000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":4175,"bidCount":0,"delayCount":0,"applyCount":2,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":609958206355,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609958206355.htm","status":"doing","title":"余姚市城区金色兰庭18幢904室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB1rktJqoz1gK0jSZLeKo_9kVXa","initialPrice":830000.00,"currentPrice":830000.00,"consultPrice":1175200.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":2468,"bidCount":1,"delayCount":0,"applyCount":3,"catNames":"","collateralCatName":"","xmppVersion":"3","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":609957402324,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609957402324.htm","status":"doing","title":"余姚市城区金色兰庭17幢701室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i1/TB15iNIqbr1gK0jSZFD2Fr9yVXa","initialPrice":1165000.00,"currentPrice":1165000.00,"consultPrice":1325900.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":4408,"bidCount":24,"delayCount":0,"applyCount":9,"catNames":"","collateralCatName":"","xmppVersion":"26","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":609906150373,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609906150373.htm","status":"doing","title":"余姚市城区金色兰庭17幢602室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i2/TB1gVszp7L0gK0jSZFtubtQCXXa","initialPrice":920000.00,"currentPrice":920000.00,"consultPrice":1304100.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":2750,"bidCount":1,"delayCount":0,"applyCount":7,"catNames":"","collateralCatName":"","xmppVersion":"3","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":609904950544,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609904950544.htm","status":"doing","title":"余姚市城区金色兰庭17幢201室的房产","picUrl":"//img.alicdn.com/bao/uploaded/i3/TB16tEvp1T2gK0jSZFvuUVnFXXa","initialPrice":890000.00,"currentPrice":890000.00,"consultPrice":1263900.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":2604,"bidCount":0,"delayCount":0,"applyCount":5,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}{"id":609808217536,"mnNotice":false,"credit":false,"itemUrl":"//sf-item.taobao.com/sf_item/609808217536.htm","status":"doing","title":"宁波市海曙区（原鄞州区）集士港镇格兰春晨10幢46号105室的房地产","picUrl":"//img.alicdn.com/bao/uploaded/i4/TB190FWqAT2gK0jSZFkY4UIQFXa","initialPrice":1750000.00,"currentPrice":1750000.00,"consultPrice":2195000.00,"marketPrice":0,"sellOff":false,"start":1578880800000,"end":1578967200000,"timeToStart":-29790835,"timeToEnd":56609165,"viewerCount":4461,"bidCount":0,"delayCount":0,"applyCount":0,"catNames":"","collateralCatName":"","xmppVersion":"2","buyRestrictions":0,"supportLoans":0,"supportOrgLoan":1}]}`), &stu)
    //
    //fmt.Println(*stu)

    //iad, _ := sf.NextID()
    //tar := TargetUrl{Id: iad, Url: bb[i].ItemUrl, Status:true, CreateTime: time.Now()}
    //uid, e := o.Insert(&tar)

    id, err := sf.NextID()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println("sonyflake: %d", id)
    id, err = sf.NextID()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println("sonyflake: %d", id)
    id, err = sf.NextID()
    if err != nil {
        fmt.Println(err)
    }
    fmt.Println("sonyflake: %d", id)

    var targets []*AuctionTarget
    num, err := o.QueryTable("auction_target").Filter("available", true).All(&targets)
    fmt.Printf("Returned Rows Num: %d, %s", num, err)
    if err == orm.ErrNoRows {
        // 没有找到记录
        fmt.Printf("Not row found")
    } else {
        fmt.Printf("开始执行")

        for i:=0; i < len(targets); i++ {
            //wg.Add(1)
            fmt.Printf("%v", targets[i])
            wg.Add(1)
            //_, _ = o.LoadRelated(targets[i],"AuctionItem") // 这里把一对多的数据也加载出来

            go spider.NewSpider(NewMyPageProcesser(*targets[i]), "fuck").
                AddUrl(targets[i].Url, "html"). // start url, html is the responce type ("html" or Crawled result"json" or "jsonp" or "text")
                AddPipeline(pipeline.NewPipelineConsole()).                                                                                   // Print result to std output
                AddPipeline(pipeline.NewPipelineFile("/tmp/ali-auction-spider")).                                                                       // Print result in file
                OpenFileLog("/tmp").                                                                                                          // Error info or other useful info in spider will be logged in file of defalt path like "WD/log/log.2014-9-1".
                SetSleepTime("rand", 1000, 3000).                                                                                             // Sleep time between 1s and 3s.
                SetThreadnum(10).
                Run()
        }
        wg.Wait()
        fmt.Printf("执行结束")
    }

    // 定义一个cron运行器



    //AddPipeline(pipeline.NewPipelineFile("/tmp/tmpfile")). // print result in file

    // delete
    //num, err = o.Delete(&u)
    //fmt.Printf("NUM: %d, ERR: %v\n", num, err)
}
